
/*!
	\file
	\brief Settings of the application.

		\author Igor Mironchik (igor.mironchik at gmail dot com).

		Copyright (c) 2010 - 2011 Igor Mironchik

	Permission is hereby granted, free of charge, to any person
	obtaining a copy of this software and associated documentation
	files (the "Software"), to deal in the Software without
	restriction, including without limitation the rights to use,
	copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the
	Software is furnished to do so, subject to the following
	conditions:

	The above copyright notice and this permission notice shall be
	included in all copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
	EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
	OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
	NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
	HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
	WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
	FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
	OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef ESHOPHELPER__SETTINGS_HPP__INCLUDED
#define ESHOPHELPER__SETTINGS_HPP__INCLUDED

// eShopHelper include.
#include <eShopHelper/h/excel.hpp>

// C++ include.
#include <stdexcept>


namespace eShopHelper {

//
// SettingsException
//

//! Exception in processing settings file.
class SettingsException
	:	public std::runtime_error
{
public:
	explicit SettingsException( const QString & what );
	virtual ~SettingsException() throw();

	//! \return Reason of the exception.
	const QString & whatAsQString() const throw();

private:
	//! Reason of the exception.
	QString m_what;
}; // class SettingsException


//
// Settings
//

//! Settings of the application.
class Settings {
public:
	Settings();
	Settings( const Settings & s );

	~Settings();

	/*!
		Save settings.
		\throws SettingsException
	*/
	void save();
	/*!
		Load settings.
		\throws SettingsException
	*/
	void load();

	//! \return Current currency.
	Goods::Currency currency() const;
	//! \return VAT.
	double vat() const;
	//! \return Convertation index to currency 1.
	double cur1() const;
	//! \return Convertation index to currency 2.
	double cur2() const;
	//! \return Convertation index to currency 3.
	double cur3() const;
	//! \return Is price shown with VAT?
	bool isWithVAT() const;

	//! Set current currency.
	void setCurrency( Goods::Currency cur );
	//! Set VAT.
	void setVAT( double vat );
	//! Set convertation index to currency 1.
	void setCur1( double cur1 );
	//! Set convertation index to currency 2.
	void setCur2( double cur2 );
	//! Set convertation index to currency 3.
	void setCur3( double cur3 );
	//! Set should the price be shown with VAT.
	void setWithVAT( bool yes = true );

	void operator = ( const Settings & s );

private:
	//! Current currency.
	Goods::Currency m_cur;
	//! Value added tax.
	double m_vat;
	//! Convertation index to currency 1.
	double m_cur1;
	//! Convertation index to currency 2.
	double m_cur2;
	//! Convertation index to currency 3.
	double m_cur3;
	//! Is the price should be shown with VAT?
	bool m_withVAT;
}; // class Settings

} /* namespace eShopHelper */

#endif // ESHOPHELPER__SETTINGS_HPP__INCLUDED
